home *** CD-ROM | disk | FTP | other *** search
/ Codemasters Artwork Disc ECTS 2000 ( UK) / Codemasters - Artwork Disc ECTS 2000 (UK).bin / pc / xtras / medial~1 / setfx~1.dir / Internal_81_Slider Bar.ls < prev    next >
Encoding:
Text File  |  1998-12-01  |  3.7 KB  |  136 lines

  1. property pThumbSprite, pFillSprite, pArrowsSprite, pTextSprite, pTextField, pCurVal, pExtraChar, pActive, pCallBackObj, pRefcon, pRange, pMin, pMax, pSliderLeft, pSliderWidth
  2.  
  3. on new me, propList
  4.   set pFillSprite to getaProp(propList, #fillSprite)
  5.   set pThumbSprite to getaProp(propList, #thumbSprite)
  6.   set pArrowsSprite to getaProp(propList, #arrowsSprite)
  7.   set pTextSprite to getaProp(propList, #textSprite)
  8.   set pTextField to getaProp(propList, #textField)
  9.   set pMin to getaProp(propList, #min)
  10.   set pMax to getaProp(propList, #max)
  11.   set pCurVal to getaProp(propList, #cur)
  12.   set pSliderLeft to getaProp(propList, #left)
  13.   set pSliderWidth to getaProp(propList, #width)
  14.   set pExtraChar to getaProp(propList, #suffix)
  15.   set pActive to getaProp(propList, #active)
  16.   set pCallBackObj to getaProp(propList, #callback)
  17.   set pRefcon to getaProp(propList, #ref)
  18.   set pRange to pMax - pMin
  19.   SetVal(me, pCurVal)
  20.   SetEnabled(me, pActive)
  21.   return me
  22. end
  23.  
  24. on wait me, waitTime
  25.   set t to the ticks
  26.   repeat while the ticks < (t + waitTime)
  27.   end repeat
  28. end
  29.  
  30. on Arrows me
  31.   if not pActive then
  32.     exit
  33.   end if
  34.   set h1 to the locH of the clickLoc
  35.   set h2 to the locH of sprite the clickOn
  36.   if h1 < h2 then
  37.     set side to "left"
  38.     set d to -1
  39.   else
  40.     set side to "right"
  41.     set d to 1
  42.   end if
  43.   set the member of sprite pArrowsSprite to member ("horizArrows" && side)
  44.   set newVal to max(min(pCurVal + d, pMax), pMin)
  45.   SetVal(me, newVal)
  46.   if objectp(pCallBackObj) then
  47.     DoDrag(pCallBackObj, pRefcon, newVal)
  48.   end if
  49.   updateStage()
  50.   wait(me, 5)
  51.   repeat while the stillDown
  52.     if rollOver(pArrowsSprite) then
  53.       set the member of sprite pArrowsSprite to member ("horizArrows" && side)
  54.       set pCurVal to max(min(pCurVal + d, pMax), pMin)
  55.     else
  56.       set the member of sprite pArrowsSprite to member "horizArrows"
  57.     end if
  58.     SetVal(me, pCurVal)
  59.     if objectp(pCallBackObj) then
  60.       DoDrag(pCallBackObj, pRefcon, newVal)
  61.     end if
  62.     wait(me, 5)
  63.   end repeat
  64.   set the member of sprite pArrowsSprite to member "horizArrows"
  65.   if objectp(pCallBackObj) then
  66.     EndChange(pCallBackObj)
  67.   end if
  68. end
  69.  
  70. on Drag me
  71.   if not pActive then
  72.     exit
  73.   end if
  74.   repeat while the stillDown
  75.     set H to min(max(the mouseH, pSliderLeft), pSliderLeft + pSliderWidth)
  76.     set the locH of sprite pThumbSprite to H
  77.     SetFill(me)
  78.     updateStage()
  79.     set loc to the locH of sprite pThumbSprite - pSliderLeft
  80.     set pCurVal to (pRange * loc / pSliderWidth) + pMin
  81.     TextOut(me)
  82.     if objectp(pCallBackObj) then
  83.       DoDrag(pCallBackObj, pRefcon, pCurVal)
  84.     end if
  85.   end repeat
  86.   if objectp(pCallBackObj) then
  87.     EndChange(pCallBackObj)
  88.   end if
  89. end
  90.  
  91. on SetFill me
  92.   puppetSprite(pFillSprite, 1)
  93.   set fillRect to the rect of sprite pFillSprite
  94.   set the right of fillRect to the locH of sprite pThumbSprite
  95.   set the left of fillRect to pSliderLeft
  96.   set the rect of sprite pFillSprite to fillRect
  97. end
  98.  
  99. on CalcVal me, numerator, denom, otherDenom
  100.   set val to otherDenom * numerator / denom
  101.   return val
  102. end
  103.  
  104. on TextOut me
  105.   if voidp(pCurVal) then
  106.     put " " into field pTextField
  107.   else
  108.     put string(integer(pCurVal)) & pExtraChar into field pTextField
  109.   end if
  110. end
  111.  
  112. on SetVal me, newVal
  113.   puppetSprite(pThumbSprite, 1)
  114.   set pCurVal to newVal
  115.   if voidp(newVal) then
  116.     set newVal to pRange / 2
  117.   end if
  118.   TextOut(me)
  119.   set loc to CalcVal(me, newVal - pMin, pRange, pSliderWidth)
  120.   set the locH of sprite pThumbSprite to pSliderLeft + loc
  121.   SetFill(me)
  122. end
  123.  
  124. on SetEnabled me, enabled
  125.   set pActive to enabled
  126.   enableInterfaceElement(pFillSprite, enabled)
  127.   enableInterfaceElement(pThumbSprite, enabled)
  128.   enableInterfaceElement(pArrowsSprite, enabled)
  129.   enableInterfaceElement(pTextSprite, enabled)
  130. end
  131.  
  132. on Release me
  133.   puppetSprite(pFillSprite, 0)
  134.   puppetSprite(pThumbSprite, 0)
  135. end
  136.